﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Cememtery_Master.aspx.cs"
    Inherits="Script_Cememtery_Master" %>

<!--//
try
{  
    $(document).ready(function() 
    {
            var speed = 500;    
            var CreateDiv="<div id=\"AddDivNew\" style='display:none; margin:0px; position:absolute ;top:0px;left:0px;border-style:solid;border-color:red;border-width:1px;color:red;width:15px;height:15px; line-height:15px;overflow:hidden; cursor:hand; background:#D3B023 ; text-align:center; vertical-align:middle;' title='温馨提示:点击可弹出保存对话框'z-index='10'>新</div>";
            var AddDataDiv="<div id=\"AddDidvcontent\" style='display:none; position:absolute; top:0px; left:0px; border-style:solid; border-color:#000000; border-width:1px; background-color:#FFFFFF; width: 252px;height:80px;border:1px solid #666666;padding:5px;'z-index='100'>纪念馆馆号：<input id=\"nubid\" type=\"text\" /><br><span style='color:red;'id=\"ErrTip\" >*请正确填写您创建的纪念馆馆号,以便访问!</span><center><input type=\"button\"  id=\"SaveMemorial\"  value=\"保存\"  />&nbsp;<input id=\"CloseMemorial\" type=\"button\" value=\"取消\"   /></center></div>";
            if(parseInt(id)<=0)
            {
                alert('参数错误');
               location.href='<%=configInfo.SiteUrl %>';
            }
            $("div[id='EditDiv']").each(function(){
                   this.style.cursor="pointer";//鼠标样式
                   this.style.border="1px dashed red";//边框样式
                   
                   
                    $(this).bind('click', function(e) {
                        if($("#ModifyDidvcontent").length>0){$("#ModifyDidvcontent").remove();};
                    
                        var scrolltop=  $(document).scrollTop();//网页被卷去的Top
                        var scroolleft=$(document).scrollLeft();//网页被卷去的Left
                                              
                        var positionX=(e.originalEvent.x+scroolleft)-$(this).offset().left||e.originalEvent.layerX-$(this).offset().left||0;//获取当前鼠标相对Div的x坐标                     
                        var positionY=(e.originalEvent.y+scrolltop)-$(this).offset().top||e.originalEvent.layerY-$(this).offset().top||0;//获取当前鼠标相对Div的y坐标                    
                        var CurrDivLeft=$(this).offset().left;//当前图片的left
                        var CurrDivRight=$(this).offset().top;//当前图片的Top
                        
                         AddData(positionX,CurrDivLeft,positionY,CurrDivRight); 
                         
                        // alert(positionX+CurrDivLeft);
                        // alert(positionY+CurrDivRight);
                       // AddData(positionX,positionY); 
                                                  
                    });//点击事件      
            });
            
        var AddData=function(x,x1,y,y1)
        {     
        
        
        
            //alert(x);
            //alert(y);
              var newx=x+x1;
              var newy=y+y1; 
              var GetH=  getTotalHeight();
              var GetW=getTotalWidth();
                $(document.body).append(CreateDiv);
                                
                $("#AddDivNew").css({"top": newy-8});
                $("#AddDivNew").css({"left": newx-8});
                $("#AddDivNew").css({"display": "block"});
                
                var obj="AddDidvcontent";
                $(document.body).append(AddDataDiv);
                divh=$("#"+obj).height();
                divw=$("#"+obj).width();
                                
                if(newx+divw>=GetW)
                {
                    newx=newx-divw;
                }
                else
                {
                    newx=newx;
                }
                
                if(newy+divh>=GetH)
                {
                    newy=newy-divh;
                } 
                else
                {
                    newy=newy;
                }               
                               
                $("#"+obj).show(speed);
                $("#"+obj).css({"top":newy});
                $("#"+obj).css({"left":newx});
                $("#"+obj).css({"display": "block"});                     
                $("#AddDivNew").click(function(event) {  $("#"+obj).show(speed) });
                
                
            $("#SaveMemorial").bind('click', function(e) {
                    var NumberId=$("#nubid").val();
                    //alert(NumberId);
                   $.ajax({url:"<%=configInfo.InstallDir %>AjaxXml/InsertMemorial_Numid.aspx?lyid="+id+"&x="+x+"&y="+y+"&Num="+NumberId+"&rnd="+Math.random(),
                            type: 'GET',
                            async: true,
                            dataType: 'html',//html or xml返回的数据是html还是xml对象
                            beforeSend:function(){
                                 $("#ErrTip").html("&nbsp;<img src='<%=configInfo.InstallDir %>images/027.gif' align='absmiddle' >&nbsp;加载中....");        
                            }, 
                            error: function(html){
                                    $("#ErrTip").html("**请正确填写您创建的纪念馆馆号,以便访问!");        
                            },
                            success: function(html){
                                if(html==-1)
                                {
                                    $("#ErrTip").html("*&nbsp;未知错误!");
                                }
                                else if(html==-2)
                                {
                                    $("#ErrTip").html("*&nbsp;馆号输入有误,只能为数字");
                                }
                                else if(html==-3)
                                {
                                    $("#ErrTip").html("*&nbsp;请输入纪念馆馆号!");
                                }  
                                else if(html==-4)
                                {
                                    $("#ErrTip").html("*&nbsp;陵园ID不能为空!");
                                }  
                                else if(html==-5)
                                {
                                    $("#ErrTip").html("*&nbsp;当前纪念馆已经存在!");
                                }   
                                else if(html==-6)
                                {
                                    $("#ErrTip").html("*&nbsp;请您登录!");
                                }                                 
                                else if(html==0)                         
                                {
                                    $("#ErrTip").html("*&nbsp;馆号不存在!");
                                }
                                else  if(html==1)                       
                                {
                                    alert("陵园的纪念馆添加成功!")
                                    hideDiv();   
                                    location.reload(true);

                                }
                            }
                        });
            });
            
            
            
            
            
            $("#CloseMemorial").bind('click', function(e) {
                 hideDiv();
            });                 
                
                
                
                    
       }    
       var hideDiv=function()
       {
            $("#AddDivNew").hide(speed);
            $("#AddDidvcontent").hide(speed)    
            $("#AddDivNew").remove();
            $("#AddDidvcontent").remove();
            if($("#ModifyDidvcontent").length>0){$("#ModifyDidvcontent").remove();};
            
       }
                        
    });
}
catch(err)
{


}


function getTotalHeight(){
             
            if($.browser.msie){
                return document.compatMode == "CSS1Compat"? document.documentElement.clientHeight :
                         document.body.clientHeight;
            }else{
                return self.innerHeight;
            }
        }
function getTotalWidth (){
             
            if($.browser.msie){
                return document.compatMode == "CSS1Compat"? document.documentElement.clientWidth :
                         document.body.clientWidth;
            }else{
                return self.innerWidth;
            }
        } 









function getPageSize(){
    var xScroll, yScroll;
    if (window.innerHeight && window.scrollMaxY) {
        xScroll = document.body.scrollWidth;
        yScroll = window.innerHeight + window.scrollMaxY;
    } 
    else if (document.body.scrollHeight > document.body.offsetHeight)
    { // all but Explorer Mac
        xScroll = document.body.scrollWidth;
        yScroll = document.body.scrollHeight;
    } 
    else 
    { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
        xScroll = document.body.offsetWidth;
        yScroll = document.body.offsetHeight;
    }
    var windowWidth, windowHeight;
    if (self.innerHeight) { // all except Explorer
        windowWidth = self.innerWidth;
        windowHeight = self.innerHeight;
    } 
    else if (document.documentElement && document.documentElement.clientHeight) 
    { // Explorer 6 Strict Mode
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
    } 
    else if (document.body) 
    { // other Explorers
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }
    // for small pages with total height less then height of the viewport
    if(yScroll < windowHeight){
        pageHeight = windowHeight;
    } 
    else {
        pageHeight = yScroll;
    }
    // for small pages with total width less then width of the viewport
    if(xScroll < windowWidth){
        pageWidth = windowWidth;
    } 
    else 
    {
        pageWidth = xScroll;
    }
    arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
    return arrayPageSize;
}














//-->
<%--
<table id='q'  onClick='restart()' style='display:none;position:relative;top:5px;left:88px;border-style:solid;border-color:red;border-width:1px;color:red;width:20;height:20;cursor:hand;' border=1 bgcolor=#D3B023 cellspacing=1 cellpadding=0 bordercolorlight="#9B7D34" bordercolordark="#9B7D34" frame=box title='温馨提示:点击可弹出保存对话框。' z-index='3'>
<tr><td align=center valign=middle style="font-size:12px">新</td></tr>
</table>

     <div id='q' style=' margin:0px;display:none;  position:relative;top:100px;left:100px;border-style:solid;border-color:red;border-width:1px;color:red;width:20px;height:20px;cursor:hand; background:#D3B023 ; text-align:center; vertical-align:middle;' title='温馨提示:点击可弹出保存对话框'z-index='100'>新</div>

--%>














